<html>
<head><meta charset="utf-8"><title>is `&amp;&amp;*` necessary here? · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/is.20.60.26.26*.60.20necessary.20here.3F.html">is `&amp;&amp;*` necessary here?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="211372363"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/is%20%60%26%26%2A%60%20necessary%20here%3F/near/211372363" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/is.20.60.26.26*.60.20necessary.20here.3F.html#211372363">(Sep 26 2020 at 18:14)</a>:</h4>
<p>Is <code>&amp;&amp;*</code> really necessary <a href="https://github.com/rust-lang/rust/blame/6f9a8a7f9b9732c55511d2a2a3914e8feafc7c52/compiler/rustc_resolve/src/late/diagnostics.rs#L195">here</a>?</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">        </span><span class="k">if</span><span class="w"> </span><span class="p">[</span><span class="s">"this"</span><span class="p">,</span><span class="w"> </span><span class="s">"my"</span><span class="p">].</span><span class="n">contains</span><span class="p">(</span><span class="o">&amp;&amp;*</span><span class="n">item_str</span><span class="p">.</span><span class="n">as_str</span><span class="p">())</span><span class="w"> </span><span class="o">&amp;&amp;</span><span class="w"> </span><span class="n">is_assoc_fn</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
</code></pre></div>



<a name="211372412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/is%20%60%26%26%2A%60%20necessary%20here%3F/near/211372412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/is.20.60.26.26*.60.20necessary.20here.3F.html#211372412">(Sep 26 2020 at 18:15)</a>:</h4>
<p>Couldn't it just be <code>&amp;*</code> or something?</p>



<a name="211373706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/is%20%60%26%26%2A%60%20necessary%20here%3F/near/211373706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/is.20.60.26.26*.60.20necessary.20here.3F.html#211373706">(Sep 26 2020 at 18:49)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">item_str</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">String</span>::<span class="n">new</span><span class="p">();</span><span class="w"></span>
<span class="w">    </span><span class="p">[</span><span class="s">"this"</span><span class="p">,</span><span class="w"> </span><span class="s">"my"</span><span class="p">].</span><span class="n">contains</span><span class="p">(</span><span class="o">&amp;</span><span class="n">item_str</span><span class="p">.</span><span class="n">as_str</span><span class="p">());</span><span class="w"></span>
</code></pre></div>



<a name="211373714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/is%20%60%26%26%2A%60%20necessary%20here%3F/near/211373714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/is.20.60.26.26*.60.20necessary.20here.3F.html#211373714">(Sep 26 2020 at 18:49)</a>:</h4>
<p><strong>or</strong></p>



<a name="211373716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/is%20%60%26%26%2A%60%20necessary%20here%3F/near/211373716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/is.20.60.26.26*.60.20necessary.20here.3F.html#211373716">(Sep 26 2020 at 18:49)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">item_str</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">String</span>::<span class="n">new</span><span class="p">();</span><span class="w"></span>
<span class="w">    </span><span class="p">[</span><span class="s">"this"</span><span class="p">,</span><span class="w"> </span><span class="s">"my"</span><span class="p">].</span><span class="n">contains</span><span class="p">(</span><span class="o">&amp;&amp;*</span><span class="n">item_str</span><span class="p">);</span><span class="w"></span>
</code></pre></div>



<a name="211373763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/is%20%60%26%26%2A%60%20necessary%20here%3F/near/211373763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/is.20.60.26.26*.60.20necessary.20here.3F.html#211373763">(Sep 26 2020 at 18:50)</a>:</h4>
<p>My guess is that it was the latter, then half-changed to the current code.</p>



<a name="211373771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/is%20%60%26%26%2A%60%20necessary%20here%3F/near/211373771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/is.20.60.26.26*.60.20necessary.20here.3F.html#211373771">(Sep 26 2020 at 18:50)</a>:</h4>
<p><code>String</code> -&gt; <code>str</code> -&gt; <code>&amp;str</code> -&gt; <code>&amp;&amp;str</code></p>



<a name="211373783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/is%20%60%26%26%2A%60%20necessary%20here%3F/near/211373783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/is.20.60.26.26*.60.20necessary.20here.3F.html#211373783">(Sep 26 2020 at 18:51)</a>:</h4>
<p>the double ref is needed because <code>contains</code> takes a reference to the item</p>



<a name="211373785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/is%20%60%26%26%2A%60%20necessary%20here%3F/near/211373785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/is.20.60.26.26*.60.20necessary.20here.3F.html#211373785">(Sep 26 2020 at 18:51)</a>:</h4>
<p>and the item is a reference</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>